sysctl: don't overwrite array size variable when it is set on error earlier
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Thu, 26 Mar 2015 10:13:01 +0000 (11:13 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 26 Mar 2015 10:13:01 +0000 (11:13 +0100)
commit26da081ac91a2caa661cb5fcb2aec6929b044a4b
treef4041788189c5787408d3ebeb0f9061b9fa2c5f5
parent28fbff96c1db99b3e48755049d577e9274dd9791
sysctl: don't overwrite array size variable when it is set on error earlier

When querying CPU topology, if caller-provided array size is smaller than
number of online CPUs then, in addition to returning -ENOBUFS, sysctl is
expected to provide back this number. However, this value, stored in 'i',
is overwritten in the subsequent loop's control statement.

Make sure we don't do this by converting the loop to 'while'.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/sysctl.c